// 所有的API进行统一管理
import requests from './request'
import mockRequest from './mockAjax'

export const reqCategoryList = () => requests({ url: '/product/getBaseCategoryList', method: 'get' })
// 发请求：
export const reqGetBannerList = () => mockRequest.get('/banner')

export const reqGetFloorList = () => mockRequest.get('/floor')

// 获取搜索模块接口
export const reqGetSearchInfo = (params) => requests({ url: '/list', method: 'post', data: params })

// 获取详情页面
export const reqGetDetailInfo = (detailId) => requests({ url: `/item/${detailId}`, method: 'get' })

// 添加至购物车,发给服务器
export const reqGetAddToCart = (skuId, skuNum) => requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })

// 购物车信息
export const reqGetShopCart = () => requests({ url: '/cart/cartList', method: 'get' })

// 删除购物车
export const deleteShopCart = (skuId) => requests({ url: `/cart/deleteCart/${skuId}`, method: 'delete' })

// 修改商品选中状态
export const reqUpdateCart = (skuId, isChecked) => requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })
// 获取验证码
export const reqGetCode = (phone) => requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
// 注册用户
export const reqUserRegister = (data) => requests({ url: `/user/passport/register`, method: 'post', data })
// 登录
export const reqUserLogin = (data) => requests({ url: '/user/passport/login', method: 'post', data })
// 获取用户信息
export const reqGetUserInfo = () => requests({ url: '/user/passport/auth/getUserInfo', method: 'get', headers: { 'Content-Type': 'application/x-www-form-urlencoded' } })
// 退出登录
export const reqLogOut = () => requests({ url: '/user/passport/logout', method: 'get' })
// 获取地址信息
export const reqAddressInfo = () => requests({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })
// 获取订单
export const reqOrderInfo = () => requests({ url: '/order/auth/trade', method: 'get' })
// 提交订单
export const reqSubmitOrder = (tradeNo, data) => requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', data })
// 获取支付信息
export const reqPayInfo = (orderId) => requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })
// 获取支付订单状态
export const reqPayStatus = (orderId) => requests({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })
// 获取我的订单
export const reqMyOrderList = (page, limit) => requests({ url: `/order/auth/${page}/${limit}`, method: 'get' })